package com.cy.demo523.untitled2.src.com.cy.dao523;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Scanner;

public class Delete {
    public static void main(String[] args)throws ClassNotFoundException , SQLException {
        Connection connection = SqlCannection.getCon();
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入用户id");
        String   username = scanner.next();
        int  id = scanner.nextInt();
        String sql ="delete   from users  where id=? ";
        PreparedStatement preparedStatement  =connection .prepareStatement(sql) ;
        preparedStatement .setInt(1,id ); ;
        ResultSet resultSet  = preparedStatement .executeQuery() ;
        int i = preparedStatement.executeUpdate();
        if (i>0){
            System.out.println("删除成功");
        }
        else{
            System.out.println("删除失败");
        }
    }

}
